//
//  141_环形链表.swift
//  Swift-LeetCode
//
//  Created by 卢悦明 on 2024/1/22.
//

import UIKit
/// === 三个定好是比较内存地址
class HasCycle: NSObject {
    
    static func QA() {
        
    }
    
    func hasCycle(_ head: ListNode<Int>?) -> Bool {
        if head == nil || head?.next == nil {
            return false
        }
        var fast = head
        var slow = head?.next
        while fast != nil && slow != nil {
            fast = fast?.next?.next
            slow = slow?.next
            if fast === slow {
                return true
            }
        }
        
        return false
    }
}
